<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
    content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <title></title>
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
		<link rel="stylesheet" type="text/css"
			href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>	
		<script type="text/javascript"
			src="<c:url value="/static/js/common.js"/>"></script>		
		<script>
			function initList(listDisplayEId) {
				$('#' + listDisplayEId).datagrid(
						{
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							onDblClickRow: function (rowIndex, rowData) {  
								$('#listDisplay').datagrid('beginEdit', rowIndex);
							},
							//onSelectPage : function (){alert(1);},
							toolbar : [
							           {
			                                id : listDisplayEId + '_btn_del',
			                                text : '删除',
			                                iconCls : 'icon-cancel',
			                                handler : function() {

			                                    var row = $('#' + listDisplayEId).datagrid('getSelections');
			                                    if (row.length == 0) {
			                                        $.messager.alert('提示', '请选择一条记录操作！', 'info');
			                                        return;
			                                    } else {
			                                        var str = '{"ordId":"'+row[0]['ordId'] +'","ordDate":"'+row[0]['ordDate']+'"}'; 
			                                        //var str = {"ordId":"222","ordDate":"2015-10-10"};
			                                        var jsonFater = eval('(' + str + ')');
			                                        $.messager.confirm('提示', '是否删除该条记录？点击确认会删除所有关联订单号。', function(r) {
			                                            if (r) {
			                                                $.ajax({
			                                                    type : 'post',
			                                                    url : "<c:url value='/order/deleteOrder.do'/>",
			                                                    data : jsonFater,
			                                                    dataType : "json",//设置查询参数及提交路径
			                                                    success : function(data) {
			                                                        if(data.success){
			                                                            $.messager.alert("提示", "删除成功！", 'info');
			                                                            $('#' + listDisplayEId).datagrid('reload');

			                                                        }else{
			                                                            var message = "";
			                                                            if(data.msg == "msg001"){
                                                                            message = "删除材料的时间已过，请联系采购部。";
			                                                            }
			                                                            $.messager.alert("提示", message, 'warning');
			                                                        }
			                                                    },
			                                                    error : function() {
			                                                        $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
			                                                    }
			                                                });
			                                            }
			                                        });
			                                    }

			                                }
			                            }
							           ,
							           
                                       {
                                           id : listDisplayEId + '_btn_add',
                                           text : '添加材料',
                                           iconCls : 'icon-add',
                                           handler : function() {
                                               var row = $('#'+listDisplayEId).datagrid('getSelections');
                                               if(row.length == 0){
                                                   $.messager.alert('提示','请选择一条记录操作！','info');
                                                   return;
                                               }else{
                                                   
                                                   
                                                   var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/order/preUpdateSelectMater.do'/>"+"?ordId="+row[0]['ordId'],"sun","width=1200px,height=600px,status=no,scrollbars=yes");
                                                   new_win.focus();
                                                   $('#'+listDisplayEId).datagrid('reload');
                                               }
                                               $('#'+listDisplayEId).datagrid('clearSelections');

                                           }
                                       }
									],
							onLoadError:function(){
								$.messager.alert('错误','获取数据失败，请与管理员联系！','error');
							}
						 ,onClickRow:function(rowIndex){
								$(".myrad").prop("checked",false);
								$(".myrad").eq(rowIndex).prop("checked",true);
							} 
						
						});
				
			};
			$(document).ready(function() {
				initList('listDisplay');
			});
			
			function  goDetailedContent(val,rowData,rowIndex){
				return '<a href="#" onclick="constructionManager(\'' + rowData.ordId+ '\')">'+val+'</a>  '
			}
			
			function constructionManager(id) {
				//window.showModalDialog("<c:url value='/order/goSelectCustomDetailed.do'/>"+"?id="+id, "","dialogWidth=1200px;dialogHeight=500px,status=no");
				var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/order/goSelectCustomDetailed.do'/>"+"?id="+id,"sun","width=1200px,height=600px,status=no,scrollbars=yes");
				new_win.focus();
			}
			//下拉框
			$(function() {        
		        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
		        $('#ordState').combobox({   
		            data:[{"ordState":"0","ordStateName":"全部"},{"ordState":"1","ordStateName":"待审核"},{"ordState":"2","ordStateName":"审核通过"},{"ordState":"3","ordStateName":"审核未通过"},{"ordState":"4","ordStateName":"不需审核"}],   
		            editable:false, //不可编辑状态  
		            cache: false,  
		            valueField:'ordState',     
		            textField:'ordStateName',  
		        });      
		    }); 
			function searchInfo(){
				if($('#ordState').combobox('getValue') ==''){
					$('#listDisplay').datagrid('load', {
						ordState : 0,
						ordDate : $('#ordDate').datebox('getValue')
					}); 
				}else{
					$('#listDisplay').datagrid('load', {
						ordState : $('#ordState').combobox('getValue'),
						ordDate : $('#ordDate').datebox('getValue')
					});  
				}
			}
		</script>
			</head>
			<body>
			<form id="AddFoodForm" name="AddFoodForm" method="post">
			<table width="100%">
			<tr>
		</tr>
		<tr><td>
			<div style="height: auto; width:100%;background: #fafafa; padding: 5px;" class="easyui-panel" title="查询" iconCls="icon-search" collapsible="true" minimizable="false" maximizable="false" closable="false">
					<form id="searchForm" name="searchForm" method="post"
						action="userlist.txt"
						onsubmit="return searchDGData(this.id,'listDisplay');">
						<div>
		            	<table cellpadding="5">
								<tr>
								
									<td>审核状态：</td>
									<td><input class="easyui-combobox" id="ordState" editable="false" name="ordState"></input></td>
								</tr>
								<tr>
									<td>订单日期：</td>
									<td><input class="easyui-datebox" editable="true" id="ordDate" name="ordDate"></input></td>
									
		                    		<td><input type="button" onclick="searchInfo()" value="查询"></td>
		                    	</tr>
		                </table>					 
						</div>
					</form>
				</div>
			</td></tr>
		<td>
				<table id="listDisplay" title="我的订单列表" width="100%"
			iconCls="icon-list" singleSelect="true" idField="ordId"
			url="<c:url value="/order/findMyOrder.do?"/>" loadMsg="请稍候......"
			pagination="true" pageSize="20"
			pageList="[10,20,30,40,50,100]" sortName="foodId"
			rownumbers="true" sortOrder="asc">
			<thead>
				<tr>
				    <th field="id" width="25" align="center"  checkbox="true">
					</th> 
				    <th field="ordId" width="80"  sortable="true" >
						订单ID
					</th>	
 					<th field="ordCustId" width="80" sortable="true" >
						客户ID
					</th>		
					<th field="ordCustName" width="80" sortable="true" >
						客户名
					</th>
					<th field="ordState" width="100" formatter="formatOrdState" sortable="true" >
						订单状态
					</th>	
					<th field="ordDate" width="150"  sortable="true" >
						订单日期
					</th>	
					<th field="ordDay" width="150"  sortable="true" >
						订单日
					</th>	
					<th field="ordValue" width="100"  sortable="true" align="right">
						菜品总价钱
					</th>
					<th field="reviewRemark" width="200"  sortable="true" >
						审核不通过原因
					</th>
					<th field="content" width="110" formatter="goDetailedContent" sortable="true" >
						查看订单详细内容
					</th>		
 				</tr>
			</thead>
			</table>
			</td>
			</tr>
		</table>
		</form>
	</body>
<style>
body{margin:0;padding:0;}
.m-toolbar{
    position: relative;
    text-align: center;
    min-height: 32px;
    background-color:#e0edfe ;
}
.datagrid-row {
    height: 32px;
}

</style>
</html>